<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>分类: 技术教程 | 小小程序员</title><meta name="author" content="十一星野"><meta name="copyright" content="十一星野"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Hutool 是一个小而全的 Java 工具类库，它帮助我们简化每一行代码，避免重复造轮子。如果你有需要用到某些工具类的时候，不妨在 Hutool 里面找找。本文总结了平时常用的16个工具类，希望对大家有所帮助！  #Hutool安装Hutool的安装非常简单，Maven项目中只需在pom.xml添加以下依赖即可。 12345&lt;dependency&gt;    &lt;groupId&amp;g">
<meta property="og:type" content="article">
<meta property="og:title" content="不要再重复造轮子了，这款开源工具类库贼好使！">
<meta property="og:url" content="https://ko25891wan.gitlab.io/2024/01/6e44f3117e70.html">
<meta property="og:site_name" content="小小程序员">
<meta property="og:description" content="Hutool 是一个小而全的 Java 工具类库，它帮助我们简化每一行代码，避免重复造轮子。如果你有需要用到某些工具类的时候，不妨在 Hutool 里面找找。本文总结了平时常用的16个工具类，希望对大家有所帮助！  #Hutool安装Hutool的安装非常简单，Maven项目中只需在pom.xml添加以下依赖即可。 12345&lt;dependency&gt;    &lt;groupId&amp;g">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png">
<meta property="article:published_time" content="2024-01-21T09:28:23.000Z">
<meta property="article:modified_time" content="2024-01-21T09:28:23.939Z">
<meta property="article:author" content="十一星野">
<meta property="article:tag" content="宅男,热血">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://ko25891wan.gitlab.io/2024/01/6e44f3117e70.html"><link rel="preconnect" href="//fastly.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":1,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.staticfile.org/egjs-infinitegrid/4.11.0/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '分类: 技术教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-01-21 17:28:23'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="小小程序员"><span class="site-name">小小程序员</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">不要再重复造轮子了，这款开源工具类库贼好使！</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-21T09:28:23.000Z" title="发表于 2024-01-21 17:28:23">2024-01-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-01-21T09:28:23.939Z" title="更新于 2024-01-21 17:28:23">2024-01-21</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/">技术教程</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/">mall</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/%E5%8F%82%E8%80%83%E7%AF%87/">参考篇</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="不要再重复造轮子了，这款开源工具类库贼好使！"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><blockquote>
<p>Hutool 是一个小而全的 Java 工具类库，它帮助我们简化每一行代码，避免重复造轮子。如果你有需要用到某些工具类的时候，不妨在 Hutool 里面找找。本文总结了平时常用的16个工具类，希望对大家有所帮助！</p>
</blockquote>
<h2 id="Hutool安装"><a href="#Hutool安装" class="headerlink" title="#Hutool安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#hutool%E5%AE%89%E8%A3%85">#</a>Hutool安装</h2><p>Hutool的安装非常简单，Maven项目中只需在<code>pom.xml</code>添加以下依赖即可。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;cn.hutool&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;hutool-all&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;5.4.0&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>

<h2 id="常用工具类"><a href="#常用工具类" class="headerlink" title="#常用工具类"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB">#</a>常用工具类</h2><blockquote>
<p>使用一个工具方法代替一段复杂代码，避免<code>复制粘贴</code>代码，可以极大的提高我们的开发效率，下面介绍下我常用的工具方法！</p>
</blockquote>
<h3 id="Convert"><a href="#Convert" class="headerlink" title="#Convert"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#convert">#</a>Convert</h3><p>类型转换工具类，用于各种类型数据的转换。平时我们转换类型经常会面临类型转换失败的问题，要写<code>try catch</code>代码，有了它，就不用写了！</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">//转换为字符串</span><br><span class="line">int a = 1;</span><br><span class="line">String aStr = Convert.toStr(a);</span><br><span class="line">//转换为指定类型数组</span><br><span class="line">String[] b = &#123;&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;&#125;;</span><br><span class="line">Integer[] bArr = Convert.toIntArray(b);</span><br><span class="line">//转换为日期对象</span><br><span class="line">String dateStr = &quot;2017-05-06&quot;;</span><br><span class="line">Date date = Convert.toDate(dateStr);</span><br><span class="line">//转换为列表</span><br><span class="line">String[] strArr = &#123;&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;&#125;;</span><br><span class="line">List&lt;String&gt; strList = Convert.toList(String.class, strArr);</span><br></pre></td></tr></table></figure>

<h3 id="DateUtil"><a href="#DateUtil" class="headerlink" title="#DateUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#dateutil">#</a>DateUtil</h3><p>日期时间工具类，定义了一些常用的日期时间操作方法。JDK自带的Date和Calendar对象真心不好用，有了它操作日期时间就简单多了！</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">//Date、long、Calendar之间的相互转换</span><br><span class="line">//当前时间</span><br><span class="line">Date date = DateUtil.date();</span><br><span class="line">//Calendar转Date</span><br><span class="line">date = DateUtil.date(Calendar.getInstance());</span><br><span class="line">//时间戳转Date</span><br><span class="line">date = DateUtil.date(System.currentTimeMillis());</span><br><span class="line">//自动识别格式转换</span><br><span class="line">String dateStr = &quot;2017-03-01&quot;;</span><br><span class="line">date = DateUtil.parse(dateStr);</span><br><span class="line">//自定义格式化转换</span><br><span class="line">date = DateUtil.parse(dateStr, &quot;yyyy-MM-dd&quot;);</span><br><span class="line">//格式化输出日期</span><br><span class="line">String format = DateUtil.format(date, &quot;yyyy-MM-dd&quot;);</span><br><span class="line">//获得年的部分</span><br><span class="line">int year = DateUtil.year(date);</span><br><span class="line">//获得月份，从0开始计数</span><br><span class="line">int month = DateUtil.month(date);</span><br><span class="line">//获取某天的开始、结束时间</span><br><span class="line">Date beginOfDay = DateUtil.beginOfDay(date);</span><br><span class="line">Date endOfDay = DateUtil.endOfDay(date);</span><br><span class="line">//计算偏移后的日期时间</span><br><span class="line">Date newDate = DateUtil.offset(date, DateField.DAY_OF_MONTH, 2);</span><br><span class="line">//计算日期时间之间的偏移量</span><br><span class="line">long betweenDay = DateUtil.between(date, newDate, DateUnit.DAY);</span><br></pre></td></tr></table></figure>

<h3 id="JSONUtil"><a href="#JSONUtil" class="headerlink" title="#JSONUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#jsonutil">#</a>JSONUtil</h3><p>JSON解析工具类，可用于对象与JSON之间的互相转化。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">PmsBrand brand = new PmsBrand();</span><br><span class="line">brand.setId(1L);</span><br><span class="line">brand.setName(&quot;小米&quot;);</span><br><span class="line">brand.setShowStatus(1);</span><br><span class="line">//对象转化为JSON字符串</span><br><span class="line">String jsonStr = JSONUtil.parse(brand).toString();</span><br><span class="line">LOGGER.info(&quot;jsonUtil parse:&#123;&#125;&quot;, jsonStr);</span><br><span class="line">//JSON字符串转化为对象</span><br><span class="line">PmsBrand brandBean = JSONUtil.toBean(jsonStr, PmsBrand.class);</span><br><span class="line">LOGGER.info(&quot;jsonUtil toBean:&#123;&#125;&quot;, brandBean);</span><br><span class="line">List&lt;PmsBrand&gt; brandList = new ArrayList&lt;&gt;();</span><br><span class="line">brandList.add(brand);</span><br><span class="line">String jsonListStr = JSONUtil.parse(brandList).toString();</span><br><span class="line">//JSON字符串转化为列表</span><br><span class="line">brandList = JSONUtil.toList(new JSONArray(jsonListStr), PmsBrand.class);</span><br><span class="line">LOGGER.info(&quot;jsonUtil toList:&#123;&#125;&quot;, brandList);</span><br></pre></td></tr></table></figure>

<h3 id="StrUtil"><a href="#StrUtil" class="headerlink" title="#StrUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#strutil">#</a>StrUtil</h3><p>字符串工具类，定义了一些常用的字符串操作方法。<code>StrUtil</code>比<code>StringUtil</code>名称更短，用起来也更方便！</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">//判断是否为空字符串</span><br><span class="line">String str = &quot;test&quot;;</span><br><span class="line">StrUtil.isEmpty(str);</span><br><span class="line">StrUtil.isNotEmpty(str);</span><br><span class="line">//去除字符串的前后缀</span><br><span class="line">StrUtil.removeSuffix(&quot;a.jpg&quot;, &quot;.jpg&quot;);</span><br><span class="line">StrUtil.removePrefix(&quot;a.jpg&quot;, &quot;a.&quot;);</span><br><span class="line">//格式化字符串</span><br><span class="line">String template = &quot;这只是个占位符:&#123;&#125;&quot;;</span><br><span class="line">String str2 = StrUtil.format(template, &quot;我是占位符&quot;);</span><br><span class="line">LOGGER.info(&quot;/strUtil format:&#123;&#125;&quot;, str2);</span><br></pre></td></tr></table></figure>

<h3 id="ClassPathResource"><a href="#ClassPathResource" class="headerlink" title="#ClassPathResource"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#classpathresource">#</a>ClassPathResource</h3><p>ClassPath单一资源访问类，可以获取classPath下的文件，在Tomcat等容器下，classPath一般是WEB-INF&#x2F;classes。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">//获取定义在src/main/resources文件夹中的配置文件</span><br><span class="line">ClassPathResource resource = new ClassPathResource(&quot;generator.properties&quot;);</span><br><span class="line">Properties properties = new Properties();</span><br><span class="line">properties.load(resource.getStream());</span><br><span class="line">LOGGER.info(&quot;/classPath:&#123;&#125;&quot;, properties);</span><br></pre></td></tr></table></figure>

<h3 id="ReflectUtil"><a href="#ReflectUtil" class="headerlink" title="#ReflectUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#reflectutil">#</a>ReflectUtil</h3><p>Java反射工具类，可用于反射获取类的方法及创建对象。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">//获取某个类的所有方法</span><br><span class="line">Method[] methods = ReflectUtil.getMethods(PmsBrand.class);</span><br><span class="line">//获取某个类的指定方法</span><br><span class="line">Method method = ReflectUtil.getMethod(PmsBrand.class, &quot;getId&quot;);</span><br><span class="line">//使用反射来创建对象</span><br><span class="line">PmsBrand pmsBrand = ReflectUtil.newInstance(PmsBrand.class);</span><br><span class="line">//反射执行对象的方法</span><br><span class="line">ReflectUtil.invoke(pmsBrand, &quot;setId&quot;, 1);</span><br></pre></td></tr></table></figure>

<h3 id="NumberUtil"><a href="#NumberUtil" class="headerlink" title="#NumberUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#numberutil">#</a>NumberUtil</h3><p>数字处理工具类，可用于各种类型数字的加减乘除操作及类型判断。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">double n1 = 1.234;</span><br><span class="line">double n2 = 1.234;</span><br><span class="line">double result;</span><br><span class="line">//对float、double、BigDecimal做加减乘除操作</span><br><span class="line">result = NumberUtil.add(n1, n2);</span><br><span class="line">result = NumberUtil.sub(n1, n2);</span><br><span class="line">result = NumberUtil.mul(n1, n2);</span><br><span class="line">result = NumberUtil.div(n1, n2);</span><br><span class="line">//保留两位小数</span><br><span class="line">BigDecimal roundNum = NumberUtil.round(n1, 2);</span><br><span class="line">String n3 = &quot;1.234&quot;;</span><br><span class="line">//判断是否为数字、整数、浮点数</span><br><span class="line">NumberUtil.isNumber(n3);</span><br><span class="line">NumberUtil.isInteger(n3);</span><br><span class="line">NumberUtil.isDouble(n3);</span><br></pre></td></tr></table></figure>

<h3 id="BeanUtil"><a href="#BeanUtil" class="headerlink" title="#BeanUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#beanutil">#</a>BeanUtil</h3><p>JavaBean工具类，可用于Map与JavaBean对象的互相转换以及对象属性的拷贝。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">PmsBrand brand = new PmsBrand();</span><br><span class="line">brand.setId(1L);</span><br><span class="line">brand.setName(&quot;小米&quot;);</span><br><span class="line">brand.setShowStatus(0);</span><br><span class="line">//Bean转Map</span><br><span class="line">Map&lt;String, Object&gt; map = BeanUtil.beanToMap(brand);</span><br><span class="line">LOGGER.info(&quot;beanUtil bean to map:&#123;&#125;&quot;, map);</span><br><span class="line">//Map转Bean</span><br><span class="line">PmsBrand mapBrand = BeanUtil.mapToBean(map, PmsBrand.class, false);</span><br><span class="line">LOGGER.info(&quot;beanUtil map to bean:&#123;&#125;&quot;, mapBrand);</span><br><span class="line">//Bean属性拷贝</span><br><span class="line">PmsBrand copyBrand = new PmsBrand();</span><br><span class="line">BeanUtil.copyProperties(brand, copyBrand);</span><br><span class="line">LOGGER.info(&quot;beanUtil copy properties:&#123;&#125;&quot;, copyBrand);</span><br></pre></td></tr></table></figure>

<h3 id="CollUtil"><a href="#CollUtil" class="headerlink" title="#CollUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#collutil">#</a>CollUtil</h3><p>集合操作的工具类，定义了一些常用的集合操作。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">//数组转换为列表</span><br><span class="line">String[] array = new String[]&#123;&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;&#125;;</span><br><span class="line">List&lt;String&gt; list = CollUtil.newArrayList(array);</span><br><span class="line">//join：数组转字符串时添加连接符号</span><br><span class="line">String joinStr = CollUtil.join(list, &quot;,&quot;);</span><br><span class="line">LOGGER.info(&quot;collUtil join:&#123;&#125;&quot;, joinStr);</span><br><span class="line">//将以连接符号分隔的字符串再转换为列表</span><br><span class="line">List&lt;String&gt; splitList = StrUtil.split(joinStr, &#x27;,&#x27;);</span><br><span class="line">LOGGER.info(&quot;collUtil split:&#123;&#125;&quot;, splitList);</span><br><span class="line">//创建新的Map、Set、List</span><br><span class="line">HashMap&lt;Object, Object&gt; newMap = CollUtil.newHashMap();</span><br><span class="line">HashSet&lt;Object&gt; newHashSet = CollUtil.newHashSet();</span><br><span class="line">ArrayList&lt;Object&gt; newList = CollUtil.newArrayList();</span><br><span class="line">//判断列表是否为空</span><br><span class="line">CollUtil.isEmpty(list);</span><br></pre></td></tr></table></figure>

<h3 id="MapUtil"><a href="#MapUtil" class="headerlink" title="#MapUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#maputil">#</a>MapUtil</h3><p>Map操作工具类，可用于创建Map对象及判断Map是否为空。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">//将多个键值对加入到Map中</span><br><span class="line">Map&lt;Object, Object&gt; map = MapUtil.of(new String[][]&#123;</span><br><span class="line">    &#123;&quot;key1&quot;, &quot;value1&quot;&#125;,</span><br><span class="line">    &#123;&quot;key2&quot;, &quot;value2&quot;&#125;,</span><br><span class="line">    &#123;&quot;key3&quot;, &quot;value3&quot;&#125;</span><br><span class="line">&#125;);</span><br><span class="line">//判断Map是否为空</span><br><span class="line">MapUtil.isEmpty(map);</span><br><span class="line">MapUtil.isNotEmpty(map);</span><br></pre></td></tr></table></figure>

<h3 id="AnnotationUtil"><a href="#AnnotationUtil" class="headerlink" title="#AnnotationUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#annotationutil">#</a>AnnotationUtil</h3><p>注解工具类，可用于获取注解与注解中指定的值。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">//获取指定类、方法、字段、构造器上的注解列表</span><br><span class="line">Annotation[] annotationList = AnnotationUtil.getAnnotations(HutoolController.class, false);</span><br><span class="line">LOGGER.info(&quot;annotationUtil annotations:&#123;&#125;&quot;, annotationList);</span><br><span class="line">//获取指定类型注解</span><br><span class="line">Api api = AnnotationUtil.getAnnotation(HutoolController.class, Api.class);</span><br><span class="line">LOGGER.info(&quot;annotationUtil api value:&#123;&#125;&quot;, api.description());</span><br><span class="line">//获取指定类型注解的值</span><br><span class="line">Object annotationValue = AnnotationUtil.getAnnotationValue(HutoolController.class, RequestMapping.class);</span><br></pre></td></tr></table></figure>

<h3 id="SecureUtil"><a href="#SecureUtil" class="headerlink" title="#SecureUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#secureutil">#</a>SecureUtil</h3><p>加密解密工具类，可用于MD5加密。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">//MD5加密</span><br><span class="line">String str = &quot;123456&quot;;</span><br><span class="line">String md5Str = SecureUtil.md5(str);</span><br><span class="line">LOGGER.info(&quot;secureUtil md5:&#123;&#125;&quot;, md5Str);</span><br></pre></td></tr></table></figure>

<h3 id="CaptchaUtil"><a href="#CaptchaUtil" class="headerlink" title="#CaptchaUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#captchautil">#</a>CaptchaUtil</h3><p>验证码工具类，可用于生成图形验证码。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">//生成验证码图片</span><br><span class="line">LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);</span><br><span class="line">try &#123;</span><br><span class="line">    request.getSession().setAttribute(&quot;CAPTCHA_KEY&quot;, lineCaptcha.getCode());</span><br><span class="line">    response.setContentType(&quot;image/png&quot;);//告诉浏览器输出内容为图片</span><br><span class="line">    response.setHeader(&quot;Pragma&quot;, &quot;No-cache&quot;);//禁止浏览器缓存</span><br><span class="line">    response.setHeader(&quot;Cache-Control&quot;, &quot;no-cache&quot;);</span><br><span class="line">    response.setDateHeader(&quot;Expire&quot;, 0);</span><br><span class="line">    lineCaptcha.write(response.getOutputStream());</span><br><span class="line">&#125; catch (IOException e) &#123;</span><br><span class="line">    e.printStackTrace();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="Validator"><a href="#Validator" class="headerlink" title="#Validator"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#validator">#</a>Validator</h3><p>字段验证器，可以对不同格式的字符串进行验证，比如邮箱、手机号、IP等格式。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">//判断是否为邮箱地址</span><br><span class="line">boolean result = Validator.isEmail(&quot;macro@qq.com&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isEmail:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为手机号码</span><br><span class="line">result = Validator.isMobile(&quot;18911111111&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isMobile:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为IPV4地址</span><br><span class="line">result = Validator.isIpv4(&quot;192.168.3.101&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isIpv4:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为汉字</span><br><span class="line">result = Validator.isChinese(&quot;你好&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isChinese:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为身份证号码（18位中国）</span><br><span class="line">result = Validator.isCitizenId(&quot;123456&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isCitizenId:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为URL</span><br><span class="line">result = Validator.isUrl(&quot;http://www.baidu.com&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isUrl:&#123;&#125;&quot;, result);</span><br><span class="line">//判断是否为生日</span><br><span class="line">result = Validator.isBirthday(&quot;2020-02-01&quot;);</span><br><span class="line">LOGGER.info(&quot;Validator isBirthday:&#123;&#125;&quot;, result);</span><br></pre></td></tr></table></figure>

<h3 id="DigestUtil"><a href="#DigestUtil" class="headerlink" title="#DigestUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#digestutil">#</a>DigestUtil</h3><p>摘要算法工具类，支持MD5、SHA-256、Bcrypt等算法。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">String password = &quot;123456&quot;;</span><br><span class="line">//计算MD5摘要值，并转为16进制字符串</span><br><span class="line">String result = DigestUtil.md5Hex(password);</span><br><span class="line">LOGGER.info(&quot;DigestUtil md5Hex:&#123;&#125;&quot;, result);</span><br><span class="line">//计算SHA-256摘要值，并转为16进制字符串</span><br><span class="line">result = DigestUtil.sha256Hex(password);</span><br><span class="line">LOGGER.info(&quot;DigestUtil sha256Hex:&#123;&#125;&quot;, result);</span><br><span class="line">//生成Bcrypt加密后的密文，并校验</span><br><span class="line">String hashPwd = DigestUtil.bcrypt(password);</span><br><span class="line">boolean check = DigestUtil.bcryptCheck(password,hashPwd);</span><br><span class="line">LOGGER.info(&quot;DigestUtil bcryptCheck:&#123;&#125;&quot;, check);</span><br></pre></td></tr></table></figure>

<h3 id="HttpUtil"><a href="#HttpUtil" class="headerlink" title="#HttpUtil"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#httputil">#</a>HttpUtil</h3><p>Http请求工具类，可以发起GET&#x2F;POST等请求。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">String response = HttpUtil.get(&quot;http://localhost:8080/hutool/covert&quot;);</span><br><span class="line">LOGGER.info(&quot;HttpUtil get:&#123;&#125;&quot;, response);</span><br></pre></td></tr></table></figure>

<h3 id="其他工具类"><a href="#其他工具类" class="headerlink" title="#其他工具类"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#%E5%85%B6%E4%BB%96%E5%B7%A5%E5%85%B7%E7%B1%BB">#</a>其他工具类</h3><p>Hutool中的工具类还有很多，可以参考：<a target="_blank" rel="noopener" href="https://www.hutool.cn/">https://www.hutool.cn/</a></p>
<h2 id="项目源码地址"><a href="#项目源码地址" class="headerlink" title="#项目源码地址"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/hutool_start.html#%E9%A1%B9%E7%9B%AE%E6%BA%90%E7%A0%81%E5%9C%B0%E5%9D%80">#</a>项目源码地址</h2><p><a target="_blank" rel="noopener" href="https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-hutool">https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-hutool</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io">十一星野</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io/2024/01/6e44f3117e70.html">https://ko25891wan.gitlab.io/2024/01/6e44f3117e70.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://ko25891wan.gitlab.io" target="_blank">小小程序员</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/01/4ec2ca7d89bb.html" title="肝了一周总结的SpringBoot常用注解大全，看完就炉火纯青了！"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">肝了一周总结的SpringBoot常用注解大全，看完就炉火纯青了！</div></div></a></div><div class="next-post pull-right"><a href="/2024/01/94dcc9008f8c.html" title="SpringBoot中处理校验逻辑的两种方式，真的很机智！"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">SpringBoot中处理校验逻辑的两种方式，真的很机智！</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">十一星野</div><div class="author-info__description">归途也还可爱</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Gitlab"><i class="fab fa-gitlab" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:ko25891wan@outlook.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Hutool%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">Hutool安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E5%B7%A5%E5%85%B7%E7%B1%BB"><span class="toc-number">2.</span> <span class="toc-text">常用工具类</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Convert"><span class="toc-number">2.1.</span> <span class="toc-text">Convert</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#DateUtil"><span class="toc-number">2.2.</span> <span class="toc-text">DateUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#JSONUtil"><span class="toc-number">2.3.</span> <span class="toc-text">JSONUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#StrUtil"><span class="toc-number">2.4.</span> <span class="toc-text">StrUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ClassPathResource"><span class="toc-number">2.5.</span> <span class="toc-text">ClassPathResource</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ReflectUtil"><span class="toc-number">2.6.</span> <span class="toc-text">ReflectUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#NumberUtil"><span class="toc-number">2.7.</span> <span class="toc-text">NumberUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#BeanUtil"><span class="toc-number">2.8.</span> <span class="toc-text">BeanUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#CollUtil"><span class="toc-number">2.9.</span> <span class="toc-text">CollUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MapUtil"><span class="toc-number">2.10.</span> <span class="toc-text">MapUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#AnnotationUtil"><span class="toc-number">2.11.</span> <span class="toc-text">AnnotationUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SecureUtil"><span class="toc-number">2.12.</span> <span class="toc-text">SecureUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#CaptchaUtil"><span class="toc-number">2.13.</span> <span class="toc-text">CaptchaUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Validator"><span class="toc-number">2.14.</span> <span class="toc-text">Validator</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#DigestUtil"><span class="toc-number">2.15.</span> <span class="toc-text">DigestUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#HttpUtil"><span class="toc-number">2.16.</span> <span class="toc-text">HttpUtil</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B6%E4%BB%96%E5%B7%A5%E5%85%B7%E7%B1%BB"><span class="toc-number">2.17.</span> <span class="toc-text">其他工具类</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E6%BA%90%E7%A0%81%E5%9C%B0%E5%9D%80"><span class="toc-number">3.</span> <span class="toc-text">项目源码地址</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/c60470b9a892.html" title="Java集合使用注意事项总结">Java集合使用注意事项总结</a><time datetime="2024-02-03T04:58:22.000Z" title="发表于 2024-02-03 12:58:22">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/81fb7a201f29.html" title="无题">无题</a><time datetime="2024-02-03T03:15:31.812Z" title="发表于 2024-02-03 11:15:31">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/5737c1ec69a9.html" title="Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)">Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)</a><time datetime="2024-01-31T06:56:16.000Z" title="发表于 2024-01-31 14:56:16">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/f510db7d2f19.html" title="Spring常见面试题总结">Spring常见面试题总结</a><time datetime="2024-01-31T06:55:58.000Z" title="发表于 2024-01-31 14:55:58">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/9be065e9f288.html" title="redis 面试">redis 面试</a><time datetime="2024-01-31T06:55:55.000Z" title="发表于 2024-01-31 14:55:55">2024-01-31</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 十一星野</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.staticfile.org/instant.page/5.2.0/instantpage.min.js" type="module"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>